<?php
session_start();
ini_set("display_errors","2");
include "inc/common.php";
$serviceHour;
$account = $_SESSION['account'];
if(empty($account))
{
	header("location:http://www.hit.edu.tw/teacher.jsp");
}
else
{
	$per = $_SESSION['permission'];
	if($per != "student")
	{
		header("location:http://www.hit.edu.tw/teacher.jsp");
	}
	else
	{
		echo $_SESSION['name']."共修得".getStdHour($account)."時數，詳細列表如下：";
		echo getServiceHourDetails();
	}
}
function getClas($account)
{	
}
function getStdHour($account)
{
	global $serviceHour;
	$hours = 0;
	$criteria = new Criteria();
	$criteria->add(ServiceHourPeer::STD_NO,$account);
	$serviceHour = ServiceHourPeer::doSelect($criteria);
	for($i=0;$i<count($serviceHour);$i++)
	{
		$hours+= (integer)$serviceHour[$i]->getHour();					
	}	
	return $hours;
}
function getServiceHourDetails()
{
	global $serviceHour;
	$html="";
	if(!empty($serviceHour))
	{
		$html.= "<table>\n";
		$html.= "<tr><th>服務機構</th><th>開始時間</th><th>結束時間</th></tr>";
		for($i=0;$i<count($serviceHour);$i++)
		{
			$html.= "<tr>";
			$html.= "<td>".$serviceHour[$i]->getAgent()."</td>";
			$html.= "<td>".$serviceHour[$i]->getStartTime()."</td>";
			$html.= "<td>".$serviceHour[$i]->getEndTime()."</td>";
			$html.= "</tr>";
		}
		$html.= "</table>\n";
		return $html;
	}
}
//function 
?>
